﻿using AutoMapper;
using Benefactor.Models.DbModels;
using Benefactor.Models.DtoModels;

namespace Benefactor.Mappings;

public class MapProfile : Profile
{
    public MapProfile()
    {
        CreateMap<AddProductRequestDto, Product>();
        CreateMap<Product, ProductInfo>();
        CreateMap<UpdateProductRequestDto, Product>();

        CreateMap<AddBenefitsCardRequestDto, BenefitsCard>();
        CreateMap<BenefitsCard, BenefitsCardInfo>();
        CreateMap<UpdateBenefitsCardRequestDto, BenefitsCard>();

        CreateMap<IssueBenefitsCardThenAddOrderRequestDto, BenefitsCardOrder>()
            .ForMember(x => x.BuyerAccount, 
                options => 
                    options.MapFrom(x => x.UserId));
        CreateMap<BenefitsCardOrder, BenefitsCardOrderInfo>();

        CreateMap<AddBenefitRequestDto, Benefit>();
        CreateMap<Benefit, BenefitInfo>();
        CreateMap<Benefit, BenefitInfoWithVouchers>();
        CreateMap<UpdateBenefitRequestDto, Benefit>();

        CreateMap<CrmebProduct, CrmebProductInfo>();

        CreateMap<UseVoucherRequestDto, Voucher>();
        CreateMap<Voucher, VoucherInfo>();

        CreateMap<IssuedBenefitsCard, IssuedBenefitsCardInfo>();

        CreateMap<RefererCommissionRecord, RefererCommissionRecordInfo>();
        CreateMap<RefererCommission, RefererCommissionInfo>();
        CreateMap<AddRefererCommissionWithdrawalRequestDto, RefererCommissionWithdrawalRecord>();
        CreateMap<RefererCommissionWithdrawalRecord, RefererCommissionWithdrawalRecordInfo>();
    }
}
